var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    };
Object.defineProperty(o, "__esModule", { value: !0 });
var a = e("BaseModuleUI"),
    n = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("AudioManager"),
    s = e("Game"),
    l = e("RoleSoldierInfo"),
    _ = e("ShopViewUI"),
    c = e("dower_node_item"),
    d = e("TipViewUI"),
    h = cc._decorator,
    u = h.ccclass,
    p = h.property,
    m = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.dower_view_content = null),
                (t.dower_node_item = null),
                (t.dower_sprite = null),
                (t.dower_name_label = null),
                (t.star_node_view = null),
                (t.dower_now_info = null),
                (t.dower_next_info = null),
                (t.consume_coin_label = null),
                (t.consume_debris_label = null),
                (t.up_level_btn = null),
                (t.dower_index = 0),
                t
            );
        }
        return (
            nn(t, e),
            (t.prototype.initView = function () {
                e.prototype.initView.call(this),
                    this.showDowerInfo(),
                    this.showUpDowerInfo(0),
                    this.up_level_btn.node.on("click", this.upDowerLevel, this);
            }),
            (t.prototype.showDowerInfo = function () {
                for (var e = 0; e < 5; e++) {
                    var t = null;
                    this.dower_view_content.children[e]
                        ? (t = this.dower_view_content.children[e])
                        : (t = cc.instantiate(this.dower_node_item)).setParent(this.dower_view_content),
                        (t.active = !0),
                        t.getComponent(c.default).showDowerInfo(e);
                }
            }),
            (t.prototype.showUpDowerInfo = function (e) {
                for (var t = 0; t < this.dower_view_content.childrenCount; t++)
                    this.dower_view_content.children[t].getChildByName("light_bg").active = t == e;
                this.dower_index = e;
                var o = l.default.Dower_info[e],
                    a = n.GlobalParams.PlayerDowerInfo.value.dower[e];
                (this.dower_sprite.spriteFrame = i.default.getInstance().getDowerImagerFrame("dower_" + e)),
                    (this.dower_name_label.string = o.spirit_name),
                    (this.dower_now_info.string = o.spirit_des + "  " + o.spirit_int[a]),
                    a < o.spirit_int.length - 1
                        ? ((this.dower_next_info.string = o.spirit_des + "  " + o.spirit_int[a + 1]),
                            (this.consume_coin_label.string = "" + s.default.dower_up_level[a][0]),
                            (this.consume_debris_label.string = "" + s.default.dower_up_level[a][1]),
                            (this.up_level_btn.interactable = !0))
                        : ((this.dower_next_info.string = "已升到最高等级"),
                            (this.consume_coin_label.string = "***"),
                            (this.consume_debris_label.string = "***"),
                            (this.up_level_btn.interactable = !1));
                var r = a > this.star_node_view.childrenCount ? a : this.star_node_view.childrenCount;
                for (t = 1; t < r; t++) {
                    var _ = null;
                    this.star_node_view.children[t]
                        ? (_ = this.star_node_view.children[t])
                        : (_ = cc.instantiate(this.star_node_view.children[0])).setParent(this.star_node_view),
                        (_.active = t <= a);
                }
            }),
            (t.prototype.upDowerLevel = function () {
                var e = this;
                r.default.ButtonSound();
                var t = n.GlobalParams.PlayerDowerInfo.value,
                    o = t.dower[this.dower_index],
                    a = s.default.dower_up_level[o][0],
                    i = s.default.dower_up_level[o][1],
                    l = n.GlobalParams.PlayerInfo.value;
                l.coin < a
                    ? this.uiManager.showPopup("TipViewUI", function (t) {
                        t.getComponent(d.default).showTipInfo("金币不足\n是否前往商城购买", !1, function () {
                            e.uiManager.showPopup("ShopViewUI", function (e) {
                                e.getComponent(_.default).showChooseType("coin_btn");
                            });
                        });
                    })
                    : l.debris < i ||
                    (this.uiManager.addCoinNum(-1 * a),
                        this.uiManager.addSpNum(-1 * i),
                        this.uiManager.playerTaskOverInfo(7, 1),
                        t.dower[this.dower_index]++,
                        (n.GlobalParams.PlayerDowerInfo.value = t),
                        this.showDowerInfo(),
                        this.showUpDowerInfo(this.dower_index));
            }),
            oo([p(cc.Node)], t.prototype, "dower_view_content", void 0),
            oo([p(cc.Node)], t.prototype, "dower_node_item", void 0),
            oo([p(cc.Sprite)], t.prototype, "dower_sprite", void 0),
            oo([p(cc.Label)], t.prototype, "dower_name_label", void 0),
            oo([p(cc.Node)], t.prototype, "star_node_view", void 0),
            oo([p(cc.Label)], t.prototype, "dower_now_info", void 0),
            oo([p(cc.Label)], t.prototype, "dower_next_info", void 0),
            oo([p(cc.Label)], t.prototype, "consume_coin_label", void 0),
            oo([p(cc.Label)], t.prototype, "consume_debris_label", void 0),
            oo([p(cc.Button)], t.prototype, "up_level_btn", void 0),
            oo([u], t)
        );
    })(a.default);
o.default = m;
